package com.zh.factorymode.services.simple;

import com.zh.factorymode.services.simple.Impl.BreadImpl;
import com.zh.factorymode.services.simple.Impl.CookyImpl;

public class FoodFactory {
    public static IFood build(String name){
        IFood food = null;
        switch (name){
            case "Bread":
                food = new BreadImpl();
                break;
            case "Cooky":
                food = new CookyImpl();
                break;
        }
        return food;
    }

    public static IFood build(Class<? extends IFood> clazz){
        try{
            if (clazz != null){
                return clazz.newInstance();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
